﻿namespace EasyGo.Data
{
    using System.Data.Entity;

    using EasyGo.Logic.Model;

    public class ApplicationDbContext : DbContext
    {
        static ApplicationDbContext()
        {
            Database.SetInitializer<ApplicationDbContext>(null);
        }

        public ApplicationDbContext()
            : base("Name=data")
        {
        }

        public DbSet<User> Users { get; set; }

        public DbSet<Customer> Customers { get; set; }

        public DbSet<Project> Projects { get; set; }

        public DbSet<Component> Components { get; set; }

        public DbSet<Task> Tasks { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>().Map(x => x.ToTable("User"));
            modelBuilder.Entity<Customer>().Map(x => x.ToTable("Customer"));
            modelBuilder.Entity<Project>().Map(x => x.ToTable("Project"));
            modelBuilder.Entity<Component>().Map(x => x.ToTable("Component"));
            modelBuilder.Entity<Task>().Map(x => x.ToTable("Task"));
        }
    }
}
